<form class="layui-form" action="" method="{{ method }}">
    {% for k,item in fields %}
    <div class="layui-form-item">
        <label class="layui-form-label">{{ item.text | default(item) }}</label>
        <div class="layui-input-block">
            {% if item.type == 'radio' %}
                {% for selV,sel in item.options %}
                    <input type="radio" name="{{ k }}" value="{{ selV }}" title="{{ sel }}" {{ item.value == selV ? 'checked' : '' }}>
                {% endfor %}
            {% elseif item.type == 'select' %}
                <select name="{{ k }}" {% if validate[k].required %}required  lay-verify="required"{% endif %}>
                    {% for selV,sel in item.options %}
                    <option value="{{ selV }}">{{ sel }}</option>
                    {% endfor %}
                </select>
            {% elseif item.type == 'checkbox' %}
                {% for selV,sel in item.options %}
                    <input type="checkbox" name="{{ k }}" value="{{ selV }}" title="{{ sel }}" lay-skin="{{ item.skin }}">
                {% endfor %}
            {% elseif item.type == 'textarea' %}
                <textarea name="{{ k }}"
                          placeholder="{% if item.placeholder %}{{ item.placeholder }}{% else %}请输入{{ item.text | default(item) }}{% endif %}"
                          class="layui-textarea">{{ item.value }}</textarea>
            {% else %}
            <input type="{{ item.type | default('text') }}"
                   name="{{ k }}"
                   {% if validate[k].required %}required  lay-verify="required"{% endif %}
                   placeholder="{% if item.placeholder %}{{ item.placeholder }}{% else %}请输入{{ item.text | default(item) }}{% endif %}"
                   value="{{ item.value }}"
                   autocomplete="off" class="layui-input">
            {% endif %}
        </div>
    </div>
    {% endfor %}

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-{{ button.reset.skin }}" lay-submit lay-filter="form">{{ button.submit.text | default('立即提交') }}</button>
            <button type="reset" class="layui-btn layui-btn-{{ button.reset.skin | default('primary') }}">{{ button.reset.text | default('重置') }}</button>
        </div>
    </div>
</form>
